﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PDO.DataPersistence.Core
{
    // See the attribute guidelines at http://go.microsoft.com/fwlink/?LinkId=85236        

    /// <summary>
    /// Attribute used to decorate PersistableDataObject derived properties to designate a valiation rule.
    /// </summary>
    [global::System.AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
    public sealed class RequiredFieldAttribute : Attribute
    {
        private string _propertyName;
        private string _description;
        private bool _isRequired;

        public bool IsRequired
        {
            get { return _isRequired; }
            set { _isRequired = value; }
        }

        public string PropertyName
        {
            get { return _propertyName; }
            set { _propertyName = value; }
        }

        public string Description
        {
            get
            {
                if (null == _description)
                {
                    _description = this.GetType().Name + " input requirement";
                }
                return _description;
            }
        }

        private RequiredFieldAttribute ()
        {
        }


        public RequiredFieldAttribute(string propertyName)
            : this()
        {
            PropertyName = propertyName;
        }

    }
}
